#!/usr/local/bin/python
# Author: Jimmy Saw
# Date: 12/28/2011
# This script looks for ambiguous DNA and lowercase characters in a given sequence
# Usage: sanitycheck_dna.py sequence.fasta

import sys
import re
from Bio import SeqIO

ambig = re.compile('[K|M|R|Y|S|W|B|V|H|D|X|N]', re.IGNORECASE)
lc = re.compile('[a|c|g|t]')

seqfile = sys.argv[1]
s = SeqIO.parse(seqfile, "fasta")

counter = 0

for seqrec in s:
    print seqrec.id
    for i in range(0, len(seqrec)):
        if ambig.match(seqrec[i]):
            counter += 1
            print str(counter) + "\t" + str(i) + "\t" + seqrec[i]
        elif lc.match(seqrec[i]):
            counter += 1
            print str(counter) + "\t" + str(i) + "\t" + seqrec[i]

